package com.ivo.web.form.def;

import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;

import com.ivo.util.StringUtil;
import com.ivo.web.form.intf.Component;

public class ComponentImpl implements Component
{
	String id;
	String name;
	String style;
	String css;

	public String getId()
	{
		return id;
	}

	public void setId(String id)
	{
		this.id = id;
	}

	public String getName()
	{
		return name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public String getStyle()
	{
		return style;
	}

	public void setStyle(String style)
	{
		this.style = style;
	}

	public String getCss()
	{
		return css;
	}

	public void setCss(String css)
	{
		this.css = css;
	}

	@Override
	public String toHtml()
	{
		Document document = DocumentHelper.createDocument();
		Element div = document.addElement( "div" );
		if( StringUtil.notEmpty( id ) ) div.addAttribute( "id", id );
		if( StringUtil.notEmpty( name ) ) div.addAttribute( "name", name );
		if( StringUtil.notEmpty( style ) ) div.addAttribute( "style", style );
		if( StringUtil.notEmpty( css ) ) div.addAttribute( "css", css );
		//-------------------------------------------------------------------
		return div.asXML();
	}

}